package com.hubery.designpattern.design.template.commodity.impl;

import com.hubery.designpattern.design.chain.dto.ChainCtxDTO;
import com.hubery.designpattern.design.template.commodity.AbstractCommodityTemplate;
import com.hubery.designpattern.dto.PrizeProvideReqDTO;
import com.hubery.designpattern.enums.ChainBizTypeEnum;
import com.hubery.designpattern.enums.PrizeTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 优惠券发放策略
 *
 * @author lixueyang
 * @since 2023/2/27 20:35
 */
@Slf4j
@Component
public class CouponCommodityService extends AbstractCommodityTemplate {

    @Override
    public Object provide(PrizeProvideReqDTO reqDTO) {
        log.info("发放的奖品是 【优惠券】");

        return null;
    }

    @Override
    public void afterHandle(Object o) {
        log.info("执行发放【优惠券】后置操作");
        chainManageService.buildChain(new ChainCtxDTO(), ChainBizTypeEnum.GENERATE_COUPON);
    }

    @Override
    public PrizeTypeEnum getPrizeTypeEnum() {
        return PrizeTypeEnum.COUPON;
    }
}
